package roboticsfmw.sample;
import org.apache.log4j.BasicConfigurator;

import roboticsfmw.common.MainEngineProcessor;
import roboticsfmw.common.ShutdownEvent;
import roboticsfmw.core.EngineRuntime;
import roboticsfmw.core.HardwareException;
import roboticsfmw.core.ProcessorException;
import roboticsfmw.core.SensorException;
import roboticsfmw.core.Timer;

public class MyRobot {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		// it's necessary to provide some log4j configuration to engine
		BasicConfigurator.configure();

		EngineRuntime engine = new EngineRuntime();
		
		// Hardwares
		engine.registerHardware("/hw/userIO", new UserIOHardwareProxy());
		
		// Sensors
		engine.registerSensor(new CommandSensor());
		
		// Processors
		engine.registerProcessor(new MainEngineProcessor()); // take care of ShutdownEvent
		engine.registerProcessor(new CommandProcessor());
		
		// Timers
		engine.registerTimer("/timer/timeout", new Timer("TimeoutTimer",10000,new ShutdownEvent("Programmed End!")));
		
		try {
			engine.startAll();
		} catch (HardwareException e) {
			e.printStackTrace();
		} catch (SensorException e) {
			e.printStackTrace();
		} catch (ProcessorException e) {
			e.printStackTrace();
		}
		
	}

}
